import {
	mapGetters
} from 'vuex'

export default {
	computed: {
		...mapGetters({
			dict: 'dict/getDict'
		})
	},
	methods: {
		dictFilter(val, feild, { key = 'value', labelKey = 'label', other = '其他' } = {}) {
			if (this.dict[feild]) {
				const options = (this.dict[feild] || [])
				const item = options.find(x => String(x[key]) === String(val))
				return item ? item[labelKey] : other
			}
			return other;
		},
	}
}
